/*
 * @Author: Leo.wang wanglizhigs@163.com
 * @Date: 2024-05-11 22:12:11
 * @LastEditors: Leo.wang wanglizhigs@163.com
 * @LastEditTime: 2024-05-12 20:33:27
 * @FilePath: /gptfront-dev/src/pages/index/hooks.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { computed, ref, watchEffect } from 'vue'
import useAIModelStore from '@/store/modules/AIModel';
import { getRandomList, getList } from '@/api/chat'
import { onLoad } from '@dcloudio/uni-app';


export function useAIModel(props) {
  const AIModelStore = useAIModelStore();
  const AIModel = computed(() => AIModelStore.AIModel)

  watchEffect(() => {
    AIModelStore.toggleAIModel(props.chatMode)
  })

  function toggleByVersionAction(version){
    AIModelStore.toggleByVersion(version)
  }

  function toggleAIModelAction(name){
    AIModelStore.toggleAIModel(name)
  }
 
  return {
    AIModel,
    toggleByVersionAction,
    toggleAIModelAction
  }
}


export function useRandoms() {
  const randomList = ref([])
  




  onLoad(() => {
    getRandomList().then((result) => {
      randomList.value = result || []
    })
    // getList().then((result) => {
    //   console.log('getList', result)
    // })
  })

  return {
    randomList
  }
}